#!/usr/bin/env python
# -*-coding:UTF-8 -*-
'''
@Project ：爬虫-波波老师
@File：24-代理ip.py
@Author ：文非
@Date：2021/3/1221:37
@Require： ip 访问频率太高 ---- 门户网站的反爬措施  ip被服务器端封掉了
'''

import requests

def main():
    # UA伪装
    headers = {
        'User-Agent': "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36"
    }
    # 指定url
    url = "https://www.baidu.com/s?wd=ip"
    # 发送请求
    params = {
        "wd": "ip"
    }
    proxies={
        "https":"https://218.60.8.83:3129"
    }
    page = requests.get(url=url,headers=headers,proxies=proxies)
    page.encoding="utf-8"
    page =page.text
    # 获取响应数据
    with open("./ip.html","w",encoding="utf-8")as fp:
        fp.write(page)
    print(page)
    # 持久性存储数据

if __name__ == "__main__":
    main()